package frame.laxcen.response;

import frame.laxcen.BaseFrame;
import frame.laxcen.dataobject.DataObject_0001_01;
import frame.laxcen.exception.IllegalFrameFormatException;
import frame.laxcen.response.annotation.FrameFeature;
import frame.laxcen.util.FrameReader;
import frame.util.ByteUtil;

import java.util.HashMap;
import java.util.Map;

// 返回基带软件版本
@FrameFeature(MessageType = 0b0001, Mid = 0x01)
public class Response_0001_01 extends BaseResponse {

    public Response_0001_01(BaseFrame baseFrame) throws IllegalFrameFormatException {

        super(baseFrame);

        getContentMap().putAll(explainToMap());
    }

    @Override
    protected Map<String, String> analyzeResponse(FrameReader reader) throws IllegalFrameFormatException {

        Map<String, String> result = new HashMap<>();

        // 基带软件版本

        byte[] version = ByteUtil.intToBytes(reader.readU32());

        result.put("基带软件版本", String.format("V %d.%d.%d", version[1], version[2], version[3]));

        return result;
    }

    public DataObject_0001_01 getDataObject() {

        return new DataObject_0001_01(getContentMap());
    }
}
